var index = 0,
	flag = 0,
	cur = 0,
	page = document.getElementsByClassName("nextpage");

var wrap = document.querySelector('#move_page');
// 初始化手指坐标点
var startPoint = 0;
var currPoint = 0;
var disY = 0;
//手指按下
wrap.addEventListener("touchstart", function(e) {
	startPoint = e.changedTouches[0].pageY;
});
//手指滑动
wrap.addEventListener("touchmove", function(e) {
	currPoint = e.changedTouches[0].pageY;
	disY = currPoint - startPoint;
});
//当手指抬起的时候，判断图片滚动
wrap.addEventListener("touchend", function(e) {
	//	for(var i = 0; i < page.length; i++) {
	//		page[i].style.opacity = "0";
	//	}
	//	setTimeout(function(){page[cur].style.display = "none"},500);
	if(disY > 0) {
		page[flag].style.animationName = "fadeOutDown";
		if(index == 0) {
			index = 3;
			//			page[index].style.opacity = "1";
			page[index].style.animationName = "fadeInDown";
			flag = index;

		} else {
			index = index - 1;
			//			page[index].style.display = "block";
			page[index].style.animationName = "fadeInDown";
			flag = index;
		}
	}
	if(disY < 0) {
		page[flag].style.animationName = "fadeOutUp";
		//		setTimeout(function(){page[index].style.display = "none"},500);
		if(index == 3) {
			index = 0;
			//			page[index].style.display = "block";
			page[index].style.animationName = "fadeInUp";
			flag = index;
		} else {
			index = index + 1;
			//			page[index].style.display = "block";
			page[index].style.animationName = "fadeInUp";
			flag = index;
		}
	}
});
document.querySelector('section').addEventListener('touchstart', function(ev) {
	event.preventDefault();
});
document.querySelector('#foot_index').addEventListener('onclick', function() {
	window.open('index.html','_self');
});
document.querySelector('#foot_about').addEventListener('onclick', function() {
	window.open('about.html','_self');
});
document.querySelector('#foot_source').addEventListener('onclick', function() {
	window.open('source.html','_self');
});
document.querySelector('#foot_course').addEventListener('onclick', function() {
	window.open('course.html','_self');
});